package com.braveo.dict;

public final class BraveImageObject {
	private final int imageId;
	private final int wordId;
	private final String imageTitle;
	private final String originalFileName;
	private final String mimeType;
	private final byte[] imageData;
	
	public final static class Builder {
		private int imageId;
		private int wordId;
		private String imageTitle;
		private String originalFileName;
		private String mimeType;
		private byte[] imageData;
		
		public Builder setImageData(byte[] imageData) {
			this.imageData = imageData;
			return this;
		}
		
		public Builder setImageId(int imageId) {
			this.imageId = imageId;
			return this;
		}
		public Builder setWordId(int wordId) {
			this.wordId = wordId;
			return this;
		}
		public Builder setImageTitle(String imageTitle) {
			this.imageTitle = imageTitle;
			return this;
		}
		public Builder setOriginalFileName(String originalFileName) {
			this.originalFileName = originalFileName;
			return this;
		}
		public Builder setMimeType(String mimeType) {
			this.mimeType = mimeType;
			return this;
		}
		
		public BraveImageObject build() {
			if(imageId<=0) {
				throw new IllegalArgumentException("imageId");
			}
			if(wordId<=0) {
				throw new IllegalArgumentException("wordId");
			}
			if(originalFileName == null) {
				throw new IllegalArgumentException("originalFileName");
			}
			if(mimeType == null) {
				throw new IllegalArgumentException("mimeType");
			}
			if(imageData == null) {
				throw new IllegalArgumentException("imageData");
			}
			
			return new BraveImageObject(imageId, wordId, imageTitle, 
					originalFileName, mimeType, imageData);
		}
	}
	
	private BraveImageObject(int imageId, int wordId, String imageTitle,
			String originalFileName, String mimeType, byte[] imageData) {
		this.imageId = imageId;
		this.wordId = wordId;
		this.imageTitle = imageTitle;
		this.originalFileName = originalFileName;
		this.mimeType = mimeType;
		this.imageData = imageData;
	}

	public int getImageId() {
		return imageId;
	}

	public int getWordId() {
		return wordId;
	}

	public String getImageTitle() {
		return imageTitle;
	}

	public String getOriginalFileName() {
		return originalFileName;
	}

	public String getMimeType() {
		return mimeType;
	}
	
	public byte[] getImageData() {
		return imageData;
	}
	
}
